package chkui.springcore.example.common;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.springframework.util.StringUtils;

final public class _G {
	static public void print(Object... infos) {
		StringBuilder sb = new StringBuilder();
		if (null != infos) {
			for (Object info : infos) {
				sb.append(info);
			}
		} else {
			sb.append("null");
		}
		System.out.println(sb.toString());
	}

	static public void setValue(Object obj, String fieldName, Object value) throws NoSuchMethodException,
			SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException {
		setValueReflect(obj, fieldName, value);
	}

	static private void setValueReflect(Object obj, String fieldName, Object value) throws NoSuchMethodException,
			SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		Method method = obj.getClass().getDeclaredMethod("set" + StringUtils.capitalize(fieldName), String.class);
		method.invoke(obj, value);
	}
}
